package com.wzdigit.wms.hm.common.enums;

import java.util.*;

/**
 * 事务类型
 */
public enum AsnTypeEnum implements BaseEnum {

    PRD_RECEIVE("R01","生产入库","生产入库"),
    PO_RECEIVE("R02","采购入库","采购入库"),
    TRANSFER_RECEIVE("R03","调拨入库","调拨入库"),
    CUSTOMER_RETURN_RECEIVE("R04","销售退货","销售退货"),
    RETURN_RECEIVE("R05","还机(料)入库","还机(料)入库"),
    FREE_RECEIVE("R06","免费入库","免费入库"),
    NOT_CONTRACT_RECEIVE("R07","无合同入库","无合同入库"),
    R08("R08","零部件入库","零部件入库"),
    R09("R09","公司间发货入库","公司间发货入库"),
    R10("R10","公司间退货入库","公司间退货入库"),
    R98("R98","初始化入库","初始化入库"),
    OTHER_RECEIVE("R99","其它入库","其它入库");

    /**
     * 枚举值
     */
    public String code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     */
    public String description;

    AsnTypeEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    AsnTypeEnum(String code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static AsnTypeEnum getEnumByCode(String enumCode) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        AsnTypeEnum samplingEnum = null;

        for (AsnTypeEnum value : values) {
            if (value.getCode().equals(enumCode)) {
                samplingEnum = value;
                break;
            }
        }
        return samplingEnum;
    }

    public static AsnTypeEnum getEnumByName(String enumName) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        AsnTypeEnum repairEnum = null;

        for (AsnTypeEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public static String getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<String, String> getEnumByDescription() {
        Map<String, String> enumMap = new HashMap<String, String>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
        	enumMap.put(value.getCode(), value.getEnumName());
        }
        return enumMap;
    }
    
    public static Map<String, String> getEnumByDescription(String enumDescription) {
        Map<String, String> enumMap = new HashMap<String, String>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
